package com.wfm.leetcode.editor.cn;
public class POne768交替合并字符串{
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public String mergeAlternately(String word1, String word2) {
        int i = 0;
        int j = 0;
        StringBuilder sb = new StringBuilder();
        int cnt = 0;
        while (i<word1.length()&&j<word2.length()){
            if(cnt%2==0){
                sb.append(word1.charAt(i));
                i++;
            }else {
                sb.append(word2.charAt(j));
                j++;
            }
            cnt++;
        }
        while (i<word1.length()){
            sb.append(word1.charAt(i));
            i++;
        }
        while (j<word2.length()){
            sb.append(word2.charAt(j));
            j++;
        }
        return sb.toString();
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) { 
        Solution solution = new POne768交替合并字符串().new Solution();
        String s = solution.mergeAlternately("abc", "pqr");
        System.out.println(s);
    }
}